class Customer < ActiveRecord::Base
  acts_as_paranoid

  belongs_to :province, class_name: Region
  belongs_to :city, class_name: Region
  belongs_to :district, class_name: Region

  has_many :sales
  has_one :car, dependent: :destroy

  accepts_nested_attributes_for :car, allow_destroy: true , reject_if: :all_blank

  def has_car
    (self.car && self.car.persisted?)
  end

  def full_address
    "#{region_address}#{street}#{address}"
  end

  def region_address
    "#{province.try :alias}#{city.try :alias}#{district.try :alias}"
  end
end
